﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Purchase.ApiS.AllCation.Command.Quality;
using Purchase.ErrorCode;

namespace Purchase.ApiS.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class QulityController : ControllerBase
    {
        public readonly IMediator mediator;

        public QulityController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 质检逻辑删除的方法
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<ApiResult<int>> DelQuality(DelQualityCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 添加质检信息的方法
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> AddQuality(AddQualityCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 更新质检信息方法
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> UpdQuality(UpdQualityCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
